package com.feit.client.contorller;

import com.feit.client.feign.UserServiceClient;
import com.feit.client.pojo.User;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

/**
 * @author zhaiding
 * @date 2019/3/14 15:58
 */
@RestController
public class UserController {

    @Resource
    private UserServiceClient userServiceClient;

    @RequestMapping(value = "/queryAll")
    public List<User> queryAll() {
        return userServiceClient.queryAll();
    }

    @RequestMapping(value = "/queryById")
    public User queryById(@RequestParam Integer id) {
        return userServiceClient.queryById(id);
    }

    @RequestMapping(value = "/deleteById")
    public String deleteById(@RequestParam Integer id) {
        return userServiceClient.deleteById(id);
    }


    @RequestMapping(value = "/save")
    public String save(@RequestBody User user) {
        return userServiceClient.save(user);
    }

    @RequestMapping(value = "/updateById")
    public String updateById(@RequestBody User user) {
        return userServiceClient.updateById(user);
    }
}
